package main

import (
	"demo/config"
	"demo/pkg/database"
	"demo/pkg/faker"
	"demo/router"
	"demo/utils"

	"fmt"
)

func main() {
	//初始化配置文件
	conf, err := config.ReadConfig()
	if err != nil {
		fmt.Println("Read conf failed:", err)
	}
	//初始化xorm引擎
	if err := database.CreateEngine(conf.Dbname, conf.Dburl); err != nil {
		fmt.Println("Create xorm engine failed:", err)
		return
	}
	//初始化redis
	if err := utils.InitRedisClient(); err != nil {
		fmt.Println("Create redis engine failed:", err)
		return
	}
	r := router.SetupRouters()
	faker.GenerateAndInsertRandomElectricityBills(12)
	r.Run(":31000")
}
